def addOne(list: List[Int]): List[Int] = {
  val result = list.map(x => x + 1)
  result
}

def filterEven(list: List[Int]): List[Int] = {
  val result = list.filter(x => x % 2 == 0)
  result
}

def mapReduce(list: List[Int], f_map: Int => Int, f_reduce: (Int, Int) => Int): Int = {
  val result = list.map(f_map).reduce(f_reduce)
  result
}

val list_add = List(1, 2, 3, 4, 5)
println(list_add)
println("加一之后的结果为:")
println(addOne(list_add))
println("------")
val list_filter = List(6, 7, 8, 9, 10)
println(list_filter)
println("偶数为:")
println(filterEven(list_filter))
println("-------")
val list_map_reduce = List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
val f_map = (x: Int) => x * 2
val f_reduce = (x: Int, y: Int) => x + y
println(list_map_reduce)
println("乘2之后相加的结果为:")
println(mapReduce(list_map_reduce, f_map, f_reduce))
